<?php
$this->title = "A-PMS项目管理系统-我的资产包";


$this->registerCssFile('/css/myAssetBag.css');
$this->registerCssFile('/css/paging.css');  
$this->registerCssFile('/css/uploadExcelModal.css');



$this->registerJsFile('/js/myAssetBag.js');
//$this->registerJsFile('@web/js/uploadExcelModal.js');

?>

<style type="text/css">
    .wrap > .container-fluid > .container {
        width: 100%!important;
    }
    .myBagSeachBox .container{
    box-shadow: 0px 1px 6px 0px rgba(91, 91, 91, 0.18);
    }
    
    .layui-layer-ico {
	    background: url(/image/assetPackage/close.png) no-repeat!important;
	    z-index: 99;
	}
	.layui-layer-setwin .layui-layer-close1:hover {
   	 opacity: 1;
	}
	
	.modal-content>.modal-header>.modal-nav>span{
		font-size: 16px!important;
	color: #fff!important;
	font-weight: bolder!important;
	}
</style>

<!--一键置 顶-->

	<a href="#" class="clicktop" title="返回顶部">
		<!--<img src="image/common/clickTop.png" alt=""  />-->
	</a>
<!--资产包详情搜索部分开始-->
<div class="myBagSeachBox">
    <div class="container">
        <div class="top">
            <a href="/">办公大厅</a>
            <a href="/search-package/search"> >资产管理</a>
            <a href="#"> >我的资产包</a>
        </div>
        <ul id="myTab" class="nav nav-tabs">
            <li <?= Yii::$app->request->get('packageGroup',1)==1?'class="active"':'class=""';?>  id="myPackage" >
                <a onclick="jumpGroup(this)" data-num="1" href="#myPortfolioPackage" <?= Yii::$app->request->get('packageGroup',1)==1?'aria-expanded="true"':'aria-expanded="false"';?>" data-toggle="tab">
                    我参与的资产包
                </a>
            </li>
            <li <?= Yii::$app->request->get('packageGroup',1)==2?'class="active"':'class=""';?>>
                <a onclick="jumpGroup(this)"  data-num="2" href="#myUploadPackage" <?= Yii::$app->request->get('packageGroup',1)==2?'aria-expanded="true"':'aria-expanded="false"';?>"  data-toggle="tab">
                    我上传的资产包
                </a>
            </li>
            <li <?= Yii::$app->request->get('packageGroup',1)==3?'class="active"':'class=""';?>>
                <a onclick="jumpGroup(this)"  data-num="3"  href="#myAttentionPackage" <?= Yii::$app->request->get('packageGroup',1)==3?'aria-expanded="true"':'aria-expanded="false"';?>" data-toggle="tab">
                    我关注的资产包
                </a>
            </li>
        </ul>
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade in active" id="myPortfolioPackage">
                <input class="search" type="search" placeholder="输入资产包关键字/资产包负责人" value="<?= Yii::$app->request->get('keywords','');?>"/>
                <span class="searchText">输入资产包关键字/资产包负责人</span>
                <img STYLE="width: 76px;height: 32px;margin-left: 799px;margin-top: -33px" id="packageSearch" src="/image/myAssetBag/search.png" alt="">
                <div class="state" id="packageState">
                    <span >当前状态</span>
                    <span  data-val="123" <?= Yii::$app->request->get('packageState',123)==123?'class="stateActive packageStateSearch"':'class="packageStateSearch"'?>>全部(<dataCount><?= $userPackageCount['allState']?></dataCount>)</span>
                    <span  data-val="1" <?= Yii::$app->request->get('packageState',123)==1?'class="stateActive packageStateSearch"':'class="packageStateSearch"'?>>无 (<dataCount><?= $userPackageCount['wuState']?></dataCount>)</span>
                    <span  data-val="2" <?= Yii::$app->request->get('packageState',123)==2?'class="stateActive packageStateSearch"':'class="packageStateSearch"'?>>预评估 (<dataCount><?= $userPackageCount['qidongState']?></dataCount>)</span>

                    <span  data-val="3" <?= Yii::$app->request->get('packageState',123)==3?'class="stateActive packageStateSearch"':'class="packageStateSearch"'?>>立项审批中 (<dataCount><?= $userPackageCount['lixiangState']?></dataCount>)</span>

                    <span  data-val="5" <?= Yii::$app->request->get('packageState',123)==5?'class="stateActive packageStateSearch"':'class="packageStateSearch"'?>>立项待跟进 (<dataCount><?= $userPackageCount['shourangState']?></dataCount>)</span>

                    <span  data-val="4" <?= Yii::$app->request->get('packageState',123)==4?'class="stateActive packageStateSearch"':'class="packageStateSearch"'?>>已立项 (<dataCount><?= $userPackageCount['pingguState']?></dataCount>)</span>
                </div>
            </div>
        </div>
    </div>
</div>
<!--资产包详情列表结开始-->
<div class="myBagListBox">
    <div class="container">
        <div class="row">


                <?= $this->render('package-table', [
                    'userPackageData' => $userPackageData,
                    'packageStateName'=>$packageStateName,
                    'userPackageCount'=>$userPackageCount,
                    'packageGroup' => $packageGroup,
                ]);?>
            <div class="pagingBox">
                    <?= \yii\widgets\LinkPager::widget([
                        'pagination' => $pages,
                        'nextPageLabel' => '下一页',
                        'prevPageLabel' => '上一页',
                        'firstPageLabel' => '首页',
                        'lastPageLabel' => '尾页',
                    ]); ?>

                <?php
                    $dataCount = 0;
                    $packageState = Yii::$app->request->get('packageState',123);
                    switch ($packageState){
                        case 123:
                            $dataCount = $userPackageCount['allState'];
                            break;
                        case 1:
                            $dataCount = $userPackageCount['wuState'];
                            break;
                        case 2:
                            $dataCount = $userPackageCount['qidongState'];
                            break;
                        case 3:
                            $dataCount = $userPackageCount['lixiangState'];
                            break;
                        case 4:
                            $dataCount = $userPackageCount['pingguState'];
                            break;
                        case 5:
                            $dataCount = $userPackageCount['shourangState'];
                            break;
                        default:
                            $dataCount = $userPackageCount['allState'];
                            break;
                    }
                ?>
                    <span class="totalSize"> 共<span>
    <?= $dataCount;?>
                        </span>条记录
            </div>
        </div>

        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModal">
        </div>

    </div>
    <!-- Modal -->
    <div class="modal fade" id="shenqingFW" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <?= $this->render('fangwen');?>
    </div>
    <!-- 模态窗口  结束!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

    <!-- 上传项目清单 start -->
    <input type="hidden" id="syncUploadExcel" value="<?php echo \yii\helpers\Url::toRoute('package/sync-upload-excel', true) ?>"/>
    <!-- 上传项目清单 end -->

    <!--资产包详情搜索部分结束-->
    <!--资产包详情列表结束-->


    <!--<script type="text/javascript" src="js/paging.js"></script>-->

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <!--<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>-->
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <!--<scriptsrc="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>-->
    <script type="text/javascript">
        var packageState = '<?= Yii::$app->request->get("packageState",0)?>';

        //分组搜索
        function jumpGroup(obj) {
            //默认资产包分类为1
            var packageGroup = $(obj).data('num');
            $("#myTab li").find('a').attr("aria-expanded",'false');
            $(this).attr("aria-expanded",'true')
            var keywords     = $('.search').val()==''?'':$('.search').val();
            if (packageState == 0){
                $.each($("#packageState span"), function(i, value) {
                    if ($(this).attr('class') == 'stateActive packageStateSearch'){
                        packageState = i;
                    }
                });
            }
            var showNum = 10;
            $.each($(".pageTotalBox li"), function(i, value) {
                if ($(this).attr('class') == 'pageActive'){
                    showNum = $(this).text();
                }
            });
//            var url = '/my-package/get-my-package?packageGroup='+packageGroup+'&keywords='+keywords+'&packageState='+packageState+'&showNum='+showNum;
            var url = '/my-package/get-my-package?packageGroup='+packageGroup+'&keywords='+keywords+'&packageState='+123+'&showNum='+showNum;
            window.location.href = url;
        }

        $(function(){
            var w = $(".container").width();
            var pageNumOne = '<?= $limit?>';

            // 业内导航
            $(".edit-tabs-li1").click(function(){
                $(this).addClass("active").children(".edit-tabs-ul2").show();
                $(this).siblings().removeClass("active").children(".edit-tabs-ul2").hide();

            });

            // 详情按钮
            $(".details-btn").click(function(){
                console.log("111");
                $(this).addClass("btn-primary").siblings().removeClass("btn-primary").addClass("btn-default");
            });
            //回车搜索
            document.onkeydown = function(e){
                var ev = document.all ? window.event : e;
                if(ev.keyCode==13) {

                    //默认资产包分类为1
                    var packageGroup = 1;
                    $.each($("#myTab li"), function(i, value) {
                        if ($(this).find('a').attr('aria-expanded') == "true"){
                            packageGroup = i+1;
                        }
                    });
                    var keywords     = $('.search').val()==''?'':$('.search').val();
                    if (packageState == 0){
                        $.each($("#packageState span"), function(i, value) {
                            if ($(this).attr('class') == 'stateActive packageStateSearch'){
                                packageState = i;
                            }
                        });
                    }

                    var showNum = 10;
                    $.each($(".pageTotalBox li"), function(i, value) {
                        if ($(this).attr('class') == 'pageActive'){
                            showNum = $(this).text();
                        }
                    });
                    var url = '/my-package/get-my-package?packageGroup='+packageGroup+'&keywords='+keywords+'&packageState='+packageState+'&showNum='+showNum;
                    window.location.href = url;

                }
            }
            //ajax 组装数据
            $("#packageSearch").click(function () {
                //默认资产包分类为1
                var packageGroup = 1;
                $.each($("#myTab li"), function(i, value) {
                    if ($(this).find('a').attr('aria-expanded') == "true"){
                        packageGroup = i+1;
                    }
                });
                var keywords     = $('.search').val()==''?'':$('.search').val();
                if (packageState == 0){
                    $.each($("#packageState span"), function(i, value) {
                        if ($(this).attr('class') == 'stateActive packageStateSearch'){
                            packageState = i;
                        }
                    });
                }

                var showNum = 10;
                $.each($(".pageTotalBox li"), function(i, value) {
                    if ($(this).attr('class') == 'pageActive'){
                        showNum = $(this).text();
                    }
                });
                var url = '/my-package/get-my-package?packageGroup='+packageGroup+'&keywords='+keywords+'&packageState='+packageState+'&showNum='+showNum;
                window.location.href = url;
            })
            //点击状态搜索
            $(".packageStateSearch").click(function () {
                //默认资产包分类为1
                var packageGroup = 1;
                var pageNumThis = $(".number").text();
                showNumOne = pageNumThis==''?pageNumOne:pageNumThis;
                $.each($("#myTab li"), function(i, value) {
                    if ($(this).find('a').attr('aria-expanded') == "true"){
                        packageGroup = i+1;
                    }
                });
                var keywords     = $('.search').val()==''?'':$('.search').val();
                var packageState = $(this).attr('data-val');
                var url = '/my-package/get-my-package?packageGroup='+packageGroup+'&keywords='+keywords+'&packageState='+packageState+'&showNum='+showNumOne;
                window.location.href = url;
            })
            //点击分页搜索
            $(".pageNum").click(function () {
                //默认资产包分类为1
                var packageGroup = 1;
                var pageNumThis = $(this).text();
                showNumOne = pageNumThis==''?pageNumOne:pageNumThis;
                $.each($("#myTab li"), function(i, value) {
                    if ($(this).find('a').attr('aria-expanded') == "true"){
                        packageGroup = i+1;
                    }
                });
                var keywords     = $('.search').val()==''?'':$('.search').val();
                var packageState = '<?= Yii::$app->request->get("packageState",1)?>';
                var url = '/my-package/get-my-package?packageGroup='+packageGroup+'&keywords='+keywords+'&packageState='+packageState+'&showNum='+showNumOne;
                window.location.href = url;
            })

            //上传项目清单
            $('#uploadProjectExcel').click(function(data) {
                var package_id = 0;
                var state = 0;
                $.each($(".mytable tbody tr"), function(i, value) {
                    if ($(this).find('td').find('label ').attr('class') == 'choiceimg choiceimgtrue'){
                        package_id = $(this).find('td').find('input').val();
                        state += 1;
                    }
                });

                if (state != 1){
                    layer.msg('请选择一个资产包');
                    return false;
                }

                if (package_id > 0) {
                    window.open($('#syncUploadExcel').val() + '?packageid='+ package_id);
                }
            })

            //修改协同
            $("#saveXietong").click(function (data) {
                var package_id = 1;
                var state = 0;
                var catNum = 0;
                var package_id = 0;
                $.each($(".mytable tbody tr"), function(i, value) {
                    if ($(this).find('td').find('label ').attr('class') == 'choiceimg choiceimgtrue'){
                        package_id = $(this).find('td').find('input').val();
                         state = 1;
                         catNum++;
                    }
                });
                if (state != 1){
                    layer.msg('请先选中资产包');
                }else if (catNum>1){
                    layer.msg('只能选中一个资产包');
                }else{
                    layer.open({
                        type: 2,
                        title: '修改协同',
                        shadeClose: false,
                        shade: 0,
                        area: ['800px', '90%'],
                        content: ['/package-initiation-plan/get-package-plan1?package_id='+package_id], //iframe的url
                        success: function(layero, index){
                            layer.iframeAuto(index);
                        }
                    });
                }
            })

            //修改权限
            $("#setPermission").click(function (data) {
                var package_id = 1;
                var state = 0;
                $.each($(".mytable tbody tr"), function(i, value) {
                    if ($(this).find('td').find('label ').attr('class') == 'choiceimg choiceimgtrue'){
                        package_id = $(this).find('td').find('input').val();
                        state += 1;
                    }

                });

                if (state != 1){
                    layer.msg('请先选中资产包,或只选择1个资产包');
                    return false;
                }

                if(package_id){
                    $.get('/package/set-permissions',{'package_id':package_id},function (data) {
                        if(data.status=='false'){
                            $("#myModal").html("<div style='padding:100px;color:#fff;text-align:center;font-size:26px;'>"+data.msg+"</div>");
                        }else{
                            $("#myModal").html(data);
                        }
                    })
                }
            })

            //------------------------------申请访问----fly------------------
              $(".fangwenSQ").click(function () {
                    var package_id = $(this).data('packageid');
                    $("#packageId").val(package_id)
                  $("#shenqingFW").modal();
              })

            $("#saveFWAccess").click(function () {
                var shenqingFWNote = $("#shenqingFWNote").val();
                var packageId = $("#packageId").val();

                var url = '/package-apply/access-apply'
                $.post(url,{'packageId':packageId,'shenqingFWNote':shenqingFWNote},function (res) {
                    resData = JSON.parse(res)
                    layer.msg(resData.message)
                    if (resData.code == 200){
                        $("#shenqingFW").modal('hide');
                    }
                })
            })
            //------------------------------申请访问----fly------------------
        });



    </script>
